/**
 * Created by yujianfu on 2016/11/10.
 */
import React, {Component, PropTypes} from 'react'
import {Card, Icon, Modal, Form, Input, message, Button} from 'antd'
import Styles from './Index.less'
import {fetchPost} from './../../../../../utils/request'
import moment from "moment";

const FormItem = Form.Item

class Images extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            tradeNo: props.collectionNo,
            data: [],
        }
    }

    componentWillReceiveProps(props) {
        if (this.state.collectionNo !== props.collectionNo) {
            this.setState({
                collectionNo: props.collectionNo
            }, () => {
                this.getData()
            })
        }
    }

    componentDidMount() {
        this.getData()
    }


    getData() {
        fetchPost(`/collection/v2/images/${this.state.collectionNo}`).then((res) => {
            this.setState({
                data: res.data.list
            })
        })
    }

    createContent() {
        let data = this.state.data
        let self = this
        let content = []
        if (data != null && data.length > 0) {
            data.forEach(url => {
                content.push(
                    <div style={{textAlign:"center"}}>
                        <img  width={300}  key={url} src={url}/>
                    </div>
                )
            })
        }
        return content
    }

    render() {
        return (
            <div className={Styles.detailModule}>
                <Card title={"User Profile Images"} bodyStyle={{padding: 0}} noHovering={true}>
                    {this.createContent()}
                </Card>
            </div>

        )
    }
}

Images = Form.create()(Images)
export default Images
